
package provider.WzXML;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import provider.PureDataDirectoryEntry;
import provider.PureDataEntity;
import provider.PureDataEntry;
import provider.PureDataFileEntry;

public class WZDirectoryEntry extends WZEntry implements PureDataDirectoryEntry {

    private List<PureDataDirectoryEntry> subdirs = new ArrayList<PureDataDirectoryEntry>();
    private List<PureDataFileEntry> files = new ArrayList<PureDataFileEntry>();
    private Map<String, PureDataEntry> entries = new HashMap<String, PureDataEntry>();

    public WZDirectoryEntry(String name, int size, int checksum, PureDataEntity parent) {
	super(name, size, checksum, parent);
    }

    public WZDirectoryEntry() {
	super(null, 0, 0, null);
    }

    public void addDirectory(PureDataDirectoryEntry dir) {
	subdirs.add(dir);
	entries.put(dir.getName(), dir);
    }

    public void addFile(PureDataFileEntry fileEntry) {
	files.add(fileEntry);
	entries.put(fileEntry.getName(), fileEntry);
    }

    public List<PureDataDirectoryEntry> getSubdirectories() {
	return Collections.unmodifiableList(subdirs);
    }

    public List<PureDataFileEntry> getFiles() {
	return Collections.unmodifiableList(files);
    }

    public PureDataEntry getEntry(String name) {
	return entries.get(name);
    }
}
